package gold.digger;

/**
 * Created by fanzhenyu02 on 2020/3/1.
 */
public class LC26 {

    public int removeDuplicates(int[] nums) {
        if (null == nums || nums.length <= 0) {
            return 0;
        }

        int lastValidateIndex = 0;
        for (int i = 1; i < nums.length; ++i) {
            if (nums[lastValidateIndex] == nums[i]) {
                continue;
            }
            nums[++lastValidateIndex] = nums[i];
        }

        return lastValidateIndex + 1;
    }

    public static void main(String[] args) {
        LC26 an = new LC26();
//        int[] nums = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4};
        int[] nums = {0, 1, 2, 3};
        System.out.println(an.removeDuplicates(nums));
    }
}
